<template>
  <transition name="slide">
    <!-- 之前在transition组件下加了一个div，导致动画没有效果 -->
    <div class="modal" v-show="showModal">
        <div class="mask"></div>
        <div class="modal-dialog">
          <div class="modal-header">
            <span>{{ title }}</span>
            <a href="javascript:;" class="icon-close" @click="$emit('cancel')"></a>
          </div>
          <div class="modal-body">
            <slot name="body"></slot>
          </div>
          <div class="modal-footer">
            <a href="javascript:;" class="btn" v-if="btnType == 1" @click="$emit('submit')">{{ sureText }}</a>
            <a href="javascript:;" class="btn" v-if="btnType == 2" @click="$emit('cancel')">{{ cancelText }}</a>
            <div class="btn-group" v-if="btnType == 3">
              <a href="javascript:;" class="btn" @click="$emit('submit')">{{ sureText }}</a>
              <a href="javascript:;" class="btn" @click="$emit('cancel')">{{ cancelText }}</a>
            </div>
          </div>
        </div>
      </div>
  </transition>
</template>

<script>
export default {
  name: "modal",
  props: {
    // 弹框类型，小框、中框、大框、表单 small medium large form
    modalType: {
      type: String,
      default: "form",
    },
    // 弹框标题
    title: String,
    // 按钮类型：1确定类型 2取消按钮 3确定取消
    btnType: {
      type: String,
      default: "确定",
    },
    sureText: {
      type: String,
      default: "确定",
    },
    cancelText: {
      type: String,
      default: "取消",
    },
    showModal: Boolean,

  },
};
</script>

<style lang="scss">
// 注意引入顺序
@import "./../assets/scss/mixin.scss";
@import "./../assets/scss/config.scss";
@import "./../assets/scss/modal.scss";
</style>
